/**
* @file Formation.h
* @author Andreas Karlsson
* @version 2010-01-05
**/

#pragma once

/* includes */
#include <map>
#include <vector>
#include <Math.h>

#include "../shared/shared_types.h"


namespace Putin{


class Formation
{
private:
	/**
	* Vector of world coordinate waypoints
	*/
	std::vector<Vec3f*> mRoute;

	/**
	* Map holding unit id and it's corresponding formation slotIndex.
	*/
	std::map<int,int> mSlots; // id, slotIndex

	/**
	* Map holding unit id and it's corresponding current leg along the route.
	*/
	std::map<int,int> mLegs; // id, currentLeg

	/**
	* Amount of units in the formation, used for finding next free slot.
	*/
	int reservedSlots;

	/**
	* Final facing of the formation when the goal is reached. Currently not used.
	*/
	Vec3f mFinalFacing;

public:
	Formation(void);
	Formation(std::vector<Vec3f*> r);
	~Formation(void);
	Vec3f getCurrentLeg(int id);
	Vec3f getDestination();
	Vec3f getOffsetDestination(int id);
	Vec3f getFinalFacing(){return mFinalFacing;};
	bool nextLeg(int id);
	void reserveSlot(int id, Vec3f unitPos);
	void releaseSlot(int id);
	Vec3f getOffset(int id);
	static Vec3f offset(int index);
};

} // end namespace